package com.wjp.banquet.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Author 王君平
 * @Date 2021/9/17 16:39
 * @Description  对于是和否的枚举  (java和mysql bit字段转换关系true-->1   false-->0)
 */
@Getter
@AllArgsConstructor
public enum YesOrNoEnum {

    YES(true,"是"),

    NO(false,"否"),

    ;

    private boolean code;

    private String msg;

    /**
     * 根据code返回msg
     * @param code
     * @return
     */
    public static String getNameByCode(boolean code){
        YesOrNoEnum[] enums = YesOrNoEnum.values();
        for(int i = 0; i < enums.length; i++){
            YesOrNoEnum anEnum = enums[i];
            if(anEnum.isCode() == (code)){
                return anEnum.getMsg();
            }
        }
        return null;
    }
}
